FROM golang:1.20.2-bullseye AS builder
WORKDIR /build
ENV GOPROXY https://goproxy.cn
COPY go.mod go.sum ./
RUN go mod tidy && go mod verify

COPY . .
RUN go build -v -o chaos-backend .

FROM debian:bullseye-slim AS runner
WORKDIR /app

# Default ChaosTemplate
COPY --from=builder /build/chaos-backend /app/
COPY --from=builder /build/chaos_template.yaml /app/config/chaos_template.yaml
COPY --from=builder /build/unstructured_chaos.gotmpl /app/config/unstructured_chaos.gotmpl

CMD ["/app/chaos-backend"]